import { Route, NavLink, Switch, withRouter } from "react-router-dom"
import Home from "./components/Home"
import Detail from "./components/Detail"
import { Redirect } from "react-router-dom"
function App(props) {
  return (
    <div>
      <NavLink to={"/home"} activeClassName="linkActived">
        home
      </NavLink>
      <br />
      <NavLink to={"/detail"} activeClassName="linkActived">
        detail
      </NavLink>
      <br />
      <button
        onClick={() => {
          // props.history.push("/detail", "哈哈")
          props.history.replace("/detail", "嘻嘻")
        }}
      >
        按钮
      </button>
      <hr />
      <Switch>
        <Route path="/" component={Home} exact></Route>
        <Route path="/home" component={Home}></Route>
        <Route path="/detail" component={Detail}></Route>
        <Redirect from="/home" to="/detail"></Redirect>
      </Switch>
      <hr />
    </div>
  )
}

const WithApp = withRouter(App)
export default WithApp
